﻿@model AffiliateModel

@{
    const string hideInfoBlockAttributeName = "AffiliatePage.HideInfoBlock";
    var hideInfoBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideInfoBlockAttributeName);

    const string hideCustomersBlockAttributeName = "AffiliatePage.HideCustomersBlock";
    var hideCustomersBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideCustomersBlockAttributeName, defaultValue: true);

    const string hideOrdersBlockAttributeName = "AffiliatePage.HideOrdersBlock";
    var hideOrdersBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideOrdersBlockAttributeName, defaultValue: true);
}

<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden" />

<div class="content">
    <div class="form-horizontal">
        <nop-panels id="affiliate-panels">
            <nop-panel asp-name="affiliate-info" asp-icon="fa fa-info" asp-title="@T("Admin.Affiliates.Info")" asp-hide-block-attribute-name="@hideInfoBlockAttributeName" asp-hide="@hideInfoBlock">@await Html.PartialAsync("_CreateOrUpdate.Info", Model)</nop-panel>
            @if (Model.Id > 0)
            {
                <nop-panel asp-name="affiliate-customers" asp-icon="fa fa-user" asp-title="@T("Admin.Affiliates.Customers")" asp-hide-block-attribute-name="@hideCustomersBlockAttributeName" asp-hide="@hideCustomersBlock">@await Html.PartialAsync("_CreateOrUpdate.Customers", Model)</nop-panel>
                <nop-panel asp-name="affiliate-orders" asp-icon="fa fa-cart-plus" asp-title="@T("Admin.Affiliates.Orders")" asp-hide-block-attribute-name="@hideOrdersBlockAttributeName" asp-hide="@hideOrdersBlock">@await Html.PartialAsync("_CreateOrUpdate.Orders", Model)</nop-panel>
            }
            
            @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.AffiliateDetailsBlock, additionalData = Model })
        </nop-panels>
    </div>
</div>